package com.ruyuan.eshop.buyer.controller.aftersale;

import com.ruyuan.eshop.framework.context.user.UserContext;
import com.ruyuan.eshop.framework.core.WebPage;
import com.ruyuan.eshop.common.domain.dto.RefundQueryParam;
import com.ruyuan.eshop.common.enums.CreateChannelEnum;
import com.ruyuan.eshop.common.domain.vo.RefundRecordVO;
import com.ruyuan.eshop.common.service.aftersale.AfterSaleRefundService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 售后退款相关API
 * @author pwd
 * @version 1.0
 */
@Api(description="售后退款相关API")
@RestController
@RequestMapping("/api/v1.0/after-sales/refund")
@Validated
public class RefundBuyerController {

    @Autowired
    private AfterSaleRefundService afterSaleRefundService;

    @ApiOperation(value = "获取售后退款单列表", response = RefundRecordVO.class)
    @GetMapping
    public WebPage list(@Valid RefundQueryParam param){
        param.setMemberId(UserContext.getBuyer().getUid());
        param.setCreateChannel(CreateChannelEnum.NORMAL.value());
        return afterSaleRefundService.list(param);
    }

}
